/** @file NetworkController.h
    @class NetworkController
    @brief NetworkController works as a wrapper for the engine
*/
#include "stdafx.h"

#ifndef _NetworkController_h_
#define _NetworkController_h_

#include "Controller.h"
#include "DataPacker.h"
#include "Command.h"
#include <list>
#include "Client.h"
#include "Server.h"
#include "Input.h"
#include "Controller.h"

class NetworkController : public Controller {
public:
	Server *s;
	Client *c;
	bool isServer;
	bool isClient;
	
	/** 
	* @brief Cibstructor that gets the ip to the server, if "127.0.0.1" then it is hosting it locally
	*/
	NetworkController(string ip, Model *model);

	/** 
	* @brief creates a client connection
	*/
	void createClient(Model *model);

	/** 
	* @brief creates the server connection
	*/
	void createServer(Model *model);

	/** 
	* @brief disconnects the server connection
	*/
	void terminateServer();
	
	/** 
	* @brief disconnects the client connection
	*/
	void terminateClient();

	/** 
	* @brief send commands from the locally client to the server
	*/
	void sendCommands(list<Command*> &commands);

	/** 
	* @brief updating the clients and server receivePackets()
	*/
	virtual bool update(float deltaTime);

	RakNet::BitStream bsOut;
	RakNet::SystemAddress server_address;
private:
	string m_ip;
};

#endif